package com.ta.config;

import com.ta.interceptor.LoginInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.ArrayList;

@Configuration
public class WebConfig implements WebMvcConfigurer {
    public void addInterceptors(InterceptorRegistry registry) {
         /*配置白名单*/
        ArrayList<String> pathMatch = new ArrayList<>();
        pathMatch.add("/bootstrap3/**");
        pathMatch.add("/css/**");
        pathMatch.add("/images/**");
        pathMatch.add("/js/**");

        pathMatch.add("/web/login.html");
        pathMatch.add("/web/register.html");
        pathMatch.add("/web/index.html");
        pathMatch.add("/web/product.html");

        pathMatch.add("/user/login");
        pathMatch.add("/user/reg");
        pathMatch.add("/product/find_by_priority");
        pathMatch.add("/product/find_by_time");
        pathMatch.add("/product/find_by_id");

        LoginInterceptor interceptor = new LoginInterceptor();
        registry.addInterceptor(interceptor).addPathPatterns("/**").excludePathPatterns(pathMatch);
    }

}
